home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NetNews Offline 2
/
NetNews Offline Volume 2.iso
/
news
/
comp
/
std
/
c
/
337
< prev
next >
Wrap
Text File
|
1996-08-06
|
1KB
|
28 lines
Newsgroups: comp.lang.c,comp.std.c,comp.lang.c++
Path: blackbush.xlink.net!slsv6bt!news
From: kanze@lts.sel.alcatel.de (James Kanze US/ESC 60/3/141 #40763)
Subject: Re: Floating Point arithmetic problem
In-Reply-To: harmon@pegasus.montclair.edu's message of 15 Feb 1996 02:05:35 -0500
Message-ID: <KANZE.96Feb20112957@slsvewt.lts.sel.alcatel.de>
Sender: news@lts.sel.alcatel.de
Organization: GABI Software, Sarl.
References: <c968da6jzm.fsf@damayanti.india.ti.com>
<harmon.824366374@pegasus.montclair.edu>
Date: 20 Feb 1996 10:29:57 GMT
In article <harmon.824366374@pegasus.montclair.edu>
harmon@pegasus.montclair.edu (Derek Harmon) writes:
[To effectively round to n digits precision...]
|> When epsilon is a power of 10, say 0.0001, for positive n you could try
|> epsilon * floor( d * (1.0 / epsilon)); and that might be all you need.
I'd probably try `epsilon * floor( d * (1.0 / epsilon) + 0.5)'. Otherwise,
values like 2.322199999... will become 2.3221, instead of 2.3222.
--
James Kanze Tel.: (+33) 88 14 49 00 email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
Conseils, Θtudes et rΘalisations en logiciel orientΘ objet --
-- A la recherche d'une activitΘ dans une region francophone